import pako from "pako";

export function gzip(data: any) {
  return pako.gzip(JSON.stringify(data));
}

export async function ungzip<T>(data: Blob) {
  const uncompressedData = pako.ungzip(await data.arrayBuffer(), { to: "string" });
  return JSON.parse(uncompressedData) as T;
}
